<?php
namespace app\wf\controller;
use \think\Db;
use \app\entity\Entity;
use think\Controller;
use \think\Request;
use \think\Session;
use app\common\controller\DirectoryPageBase;
class EntityInit extends DirectoryPageBase
{
	public function index($EnName,$PKVal)
    {
     if($EnName=="BP.WF.Node"){
	   
		return $this->getNode($PKVal);
	 }
	 if($EnName=="BP.WF.Template.NodeExt"){
	   
		return $this->getNodeExt($PKVal);
	 }
	 if($EnName=="BP.WF.Flow"){
	   
		return $this->getFlow($PKVal);
	 }
	 if($EnName=="BP.WF.Template.Selector"){
	   
		return $this->getSelector($PKVal);
	 }
	 if($EnName=="BP.Sys.MapData"){
	   
		return $this->getMapData($PKVal);
	 }
	}

	//获取节点属性
	public function getNode($PKVal){

		$data=Db::table('wf_node')
		->where('NodeID',$PKVal)
		->find();
		return $data;
	}
	//
	public function getNodeExt(){
		 $entity=new Entity();
        return $entity->getArray();
	}
	//获取流程属性
	public function getFlow($PKVal){
		$data=Db::table('wf_flow')
		->where('No',$PKVal)
		->find();
		return $data;
	}
	//
	public function getSelector($PKVal){
        //查询对应的节点属性
		$data=Db::table('wf_node')
		->where('NodeID',$PKVal)
		->find();
		$temporary['EndJSON']="0";
		$temporary['FK_SQLTemplate']=$data['FK_SQLTemplate'];
		$temporary['FK_SQLTemplateText']=$data['FK_SQLTemplateText'];
		$temporary['IsAutoLoadEmps']=$data['IsAutoLoadEmps'];
		$temporary['IsEnableDeptRange']=$data['IsEnableDeptRange'];
		$temporary['IsEnableStaRange']=$data['IsEnableStaRange'];
		$temporary['IsSimpleSelector']=$data['IsSimpleSelector'];
		$temporary['NodeID']=$data['NodeID'];
		$temporary['SelectorP1']=$data['SelectorP1'];
		$temporary['SelectorP2']=$data['SelectorP2'];
		$temporary['SelectorP3']=$data['SelectorP3'];
		$temporary['SelectorP4']=$data['SelectorP4'];
		//查询对应的枚举
		$enum=Db::table('sys_enum')
		->where('EnumKey','SelectorModel')
		->where('IntKey',$data['SelectorModel'])
		->find();
		$temporary['Name']='审批';
		$temporary['SelectorModel']=$enum['IntKey'];
		$temporary['SelectorModelText']=$enum['Lab'];

		return $temporary;

	}
	public function getMapData($PKVal){
		$data=Db::table('sys_mapdata')
		->where('No',$PKVal)
		->find();
		return $data;
	}
}
